The argument list to execv() must be NULL terminated--you need a NULL pointer right after your last argument. Something like firstargs[countr + 1] = NULL, before you execv(), should work.
Also, fgets(), unlike gets(), stores the newline it reads. You'll want to find it (with strchr()) and remove it, if it exists.
Thank you so much for your help. My code is now working ( I had a few logic bugs to work out on my own). I do have some general language questions from this if you (or someone else from here) wouldn't mind answering.
What exactly is the difference between *char and char[]? from my understanding when you declare
char c[10];
then c is a pointer to the first element in the array, and can be accessed like a pointer *c.
By extension: how come when creating int main() you can write:
Code:
int main(int argc, char* argv[])
and
Code:
int main(int argc char** argv)
and access argv in the program in the same way, as in
Code:
char array[] = argv[1];
even though they are different data structures?
Thanks again.
-luro